<html>
<head><meta charset="utf-8"><title>missing stackframes in backtrace · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html">missing stackframes in backtrace</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="197152535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197152535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197152535">(May 11 2020 at 14:24)</a>:</h4>
<p>I'm having the following problem: in my backtrace dump (from backtrace-rs crate), certain frames that I expect to be present are not. Is it possible that opt-level 3 is optimizing certain functions away ?</p>



<a name="197152760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197152760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197152760">(May 11 2020 at 14:26)</a>:</h4>
<p>What if you set <code>[profile.release] debug = 2</code> in your <code>Cargo.toml</code>?</p>



<a name="197152905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197152905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197152905">(May 11 2020 at 14:27)</a>:</h4>
<p>Why profile.release? I'm currently trying:</p>
<div class="codehilite"><pre><span></span><code>[profile.dev]
lto = false
opt-level = 2

[profile.test]
lto = false
opt-level = 2

[profile.dev.overrides.&quot;*&quot;]
lto = false
opt-level = 2
</code></pre></div>



<a name="197153040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197153040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197153040">(May 11 2020 at 14:28)</a>:</h4>
<p>(btw, on opt-level = 3, even the CodeLLDB debugger doesn't get the stack frame either, which makes me suspect it being inlined / optimized away.)</p>



<a name="197153083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197153083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197153083">(May 11 2020 at 14:28)</a>:</h4>
<p>(ps2: opt-level = 3 + #[inline(never)] ==&gt; stackframe still missing)</p>



<a name="197153261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197153261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197153261">(May 11 2020 at 14:29)</a>:</h4>
<p>opt-level = 2 ==&gt; missing some stackframe<br>
opt-level = 0 ==&gt; all stackframes<br>
trying opt-level = 1 next</p>



<a name="197153360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197153360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197153360">(May 11 2020 at 14:30)</a>:</h4>
<p>Ah, never mind if you're not building with <code>--release</code></p>



<a name="197153447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197153447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197153447">(May 11 2020 at 14:31)</a>:</h4>
<p>It's running <code>cargo test --package .... </code></p>



<a name="197153541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197153541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197153541">(May 11 2020 at 14:31)</a>:</h4>
<p>The <code>test</code> profile already has <code>debug = 2</code></p>



<a name="197153624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197153624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197153624">(May 11 2020 at 14:32)</a>:</h4>
<p>opt-level = 3, 2, 1 =&gt; missing some stackframe<br>
opt-level = 0 =&gt; all stackframes</p>



<a name="197153668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197153668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197153668">(May 11 2020 at 14:32)</a>:</h4>
<p>This is annoying, as I'm writing numerical code, and I want some optimization ; but I'm also doing tdd, so I want all my stackframes.</p>



<a name="197154442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197154442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Drobnak <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197154442">(May 11 2020 at 14:38)</a>:</h4>
<p>Your tests rely on knowing stackframes?</p>



<a name="197155827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197155827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197155827">(May 11 2020 at 14:48)</a>:</h4>
<p>Even</p>
<div class="codehilite"><pre><span></span><code>[profile.dev]
lto = false
opt-level = 2
debuginfo=2
debug-assertions=true
force-frame-pointers = true
force-unwind-tables = true

[profile.test]
lto = false
opt-level = 2
debuginfo=2
debug-assertions=true
force-frame-pointers = true
force-unwind-tables = true

[profile.dev.overrides.&quot;*&quot;]
lto = false
opt-level = 2
debuginfo=2
debug-assertions=true
force-frame-pointers = true
force-unwind-tables = true
</code></pre></div>


<p>doesn't work</p>



<a name="197155948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197155948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197155948">(May 11 2020 at 14:49)</a>:</h4>
<p><span class="user-mention" data-user-id="218805">@Mark Drobnak</span> : My code has lots of "todo!()"'s -- when a unit test fails, I'd like to be able to see the entire callstack. Currently some of the frames are being optimized away when opt-level &gt; 0.</p>



<a name="197156034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197156034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Drobnak <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197156034">(May 11 2020 at 14:49)</a>:</h4>
<p>Can't you just set <code>opt-level = 0</code> for tests and leave everything else alone?</p>



<a name="197156187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197156187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197156187">(May 11 2020 at 14:50)</a>:</h4>
<p>There alot of code that operates on tensors of f32's. The tests run really really slow at opt-level = 0.</p>



<a name="197156399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197156399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Drobnak <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197156399">(May 11 2020 at 14:51)</a>:</h4>
<p>Unless there's a flag to avoid inlining, that sounds like your only option.</p>



<a name="197156514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197156514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197156514">(May 11 2020 at 14:52)</a>:</h4>
<p>I've already tried #[inline(never)] and #[no_mangle].</p>



<a name="197156702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197156702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197156702">(May 11 2020 at 14:53)</a>:</h4>
<p>Optimizations generally reduce the quality of stack traces</p>



<a name="197157174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197157174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197157174">(May 11 2020 at 14:56)</a>:</h4>
<p>I'm going to throw in the towel now. This was an interesting excuse to study rustc compiler flags. Thanks to everyone for patience / ideas / suggestions.</p>



<a name="197164272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197164272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197164272">(May 11 2020 at 15:42)</a>:</h4>
<p>Could the missing stack frames have tail calls? (a call just before returning from a function without any destructors running afterwards) In that case LLVM likely replaced the call with a jump, which means that there is no way to recover the original call frame.</p>



<a name="197170939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197170939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197170939">(May 11 2020 at 16:29)</a>:</h4>
<p>JIC, you can do <code>todo!("thing 1")</code> instead of just <code>todo!()</code>. That text is printed out when triggered</p>



<a name="197174446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197174446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197174446">(May 11 2020 at 16:57)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> : I have no idea how you guessed this -- but it often is of the form:</p>
<div class="codehilite"><pre><span></span><code>panic!()
todo!()
return Err(...)
</code></pre></div>


<p>and the last statement/expr in a function (if not directly, then the last in that particular match branch)[</p>



<a name="197176630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/missing%20stackframes%20in%20backtrace/near/197176630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/missing.20stackframes.20in.20backtrace.html#197176630">(May 11 2020 at 17:15)</a>:</h4>
<p><span class="user-mention" data-user-id="299970">@zeroexcuses</span> Rust used to hide all libstd internal stack frames at the end of the backtrace. This unfortunately broke because LLVM decided to tail call from the function that indicated the start of the libstd internal stack frames (<code>__rust_begin_short_backtrace</code>) to the function it called. This meant that <code>__rust_begin_short_backtrace</code> wouldn't be part of the backtrace anymore. I remembered this problem, and thought that your problem may have been similar.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>